let t = Date.parse(new Date());
console.log('现在时间', new Date(), t);


/**
 * 1.获取时间戳
 */
var  date =  new  Date('2020-09-15 22:39:47');

// 有三种方式获取  
var  time1 = date.getTime();

    
var  time2 = date.valueOf();

    
var  time3 = Date.parse(date);

    
console.log(time1); //1528452000000

    
console.log(time2); //1528452000000

    
console.log(time3); //1600180787000
/**
 * 2. 时间戳转换为时间
 */
console.log(new Date(1600180787000));

var timeDate = new Date(1600180787000);
var year = timeDate.getFullYear();
var month = timeDate.getMonth() + 1;
var date = timeDate.getDate();
var day = timeDate.getDay();
var hour = timeDate.getHours();
var minute = timeDate.getMinutes();
var second = timeDate.getSeconds();
// minute = checkFigure(minute);
// second = checkFigure(second);
var weekday = new Array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
let d = `${year}年${month}月${date}日 ${weekday[day]} ${hour}:${minute}:${second}`;